<template>
  <div id="outerresult">
    <el-steps :active=3 simple style="margin-bottom: 20px">
      <el-step title="简介" icon="el-icon-info"></el-step>
      <el-step title="上传" icon="el-icon-upload2"></el-step>
      <el-step title="调整" icon="el-icon-setting"></el-step>
      <el-step title="结果" icon="el-icon-finished"></el-step>
    </el-steps>
    <el-row>
      <el-col :span="24">数据集 {{ FN }} 聚类结果内部指标，耗时 {{ CT }} 毫秒</el-col>
    </el-row>
    <el-divider content-position="left">Jaccard Coefficient</el-divider>
    <el-row>
      <el-col :span="12">Jaccard系数：{{ Math.round(JC * 1000) / 1000 }}</el-col>
      <el-col :span="12">
        <el-rate v-model="rateJC" disabled show-score text-color="ff9900" :score-template=textJC></el-rate>
      </el-col>
    </el-row>
    <el-divider content-position="left">Fowlkes and Mallows Index</el-divider>
    <el-row>
      <el-col :span="12">FM指数：{{ Math.round(FMI * 1000) / 1000 }}</el-col>
      <el-col :span="12">
        <el-rate v-model="rateFMI" disabled show-score text-color="ff9900" :score-template=textFMI></el-rate>
      </el-col>
    </el-row>
    <el-divider content-position="left">Rand Index</el-divider>
    <el-row>
      <el-col :span="12">Rand指数：{{ Math.round(RI * 1000) / 1000 }}</el-col>
      <el-col :span="12">
        <el-rate v-model="rateRI" disabled show-score text-color="ff9900" :score-template=textRI></el-rate>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "OuterResult",
  data() {
    return {
      FMI: 0,
      RI: 0,
      JC: 0,
      CT: 0,
      FN: "",
      rateFMI: 2.5,
      rateRI: 2.5,
      rateJC: 2.5,
      textFMI: "loading",
      textRI: "loading",
      textJC: "loading",
    }
  },
  mounted() {
    var that = this;
    axios.get("http://localhost:8080/out/result").then(
      function (response) {
        console.log(response.data)
        that.FMI = response.data.FMI;
        that.RI = response.data.RI;
        that.JC = response.data.JC;
        that.CT = response.data.COST_TIME;
        that.FN = response.data.FILE_NAME;
        var total = response.data.TOTAL;
        var posFMI = response.data.FMI_POS;
        that.textFMI = "  FM指数共计算过 " + total + " 次, 本次排名第 " + posFMI + " 名. ";
        var posRI = response.data.RI_POS;
        that.textRI = "  Rand指数共计算过 " + total + " 次, 本次排名第 " + posRI + " 名. ";
        var posJC = response.data.JC_POS;
        that.textJC = "  Jaccard系数数共计算过 " + total + " 次, 本次排名第 " + posJC + " 名. ";
        that.rateFMI = 5.0 / total * (total - posFMI + 1)
        that.rateRI = 5.0 / total * (total - posRI + 1)
        that.rateJC = 5.0 / total * (total - posJC + 1)
      }, function (err) {
      })
  }
}
</script>

<style scoped>

</style>
